import 'package:hockey/jzx_apps.dart';
import 'package:hockey/jzx_models.dart';
import 'package:hockey/services/jzx_config.dart';

class JzxBlacklistController extends GetxController {
  final itmes = <JzxBlockData>[].obs;

  @override
  void onInit() async {
    super.onInit();

    fetchData();
  }

  fetchData() async {
    showLoading();
    itmes.value = await JzxNetRepository.client.blockList();
    hideLoading();
  }

  void removeUser(int index) async {
    final item = itmes[index];
    showLoading();
    await JzxNetRepository.client
        .removeBlock({'blockUserId': item.broadcasterId});
    hideLoading();
    itmes.removeAt(index);
    showMessage('Successfully');
    //
    JzxConfigService.to.updateBlocks(item.broadcasterId);
  }
}
